package com.dragon.app.controller.auth;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dragon.app.config.annotation.Login;
import com.dragon.common.model.ResponseData;
import com.dragon.logical.service.reminder.IDoReminderService;
import com.dragon.repository.domain.dto.DoReminderDTO;
import com.dragon.repository.entity.DoReminder;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("doReminder")
@Api(tags = "待办消息提醒")
public class DoReminderController {


    @Autowired
    IDoReminderService service;


    @GetMapping("list")
    @ApiOperation(value = "获取待办消息提醒列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "status",required = true,type = "int",value = "0,未读1,已读"),
            @ApiImplicitParam(name = "page",required = true,type = "int",value = "页码"),
            @ApiImplicitParam(name = "limit",required = true,type = "int",value = "条数"),
    })
    public ResponseData<List<DoReminderDTO>> selectPage(@RequestParam Integer status, @RequestParam Integer page, @RequestParam Integer limit, @ApiParam(hidden = true) @Login Integer adminId){
        Page<DoReminder> doReminderPage = service.selectPageList(adminId,status,page,limit);
        return ResponseData.success(DoReminderDTO.convertList(doReminderPage.getRecords()),doReminderPage.getTotal());
    }


    @PostMapping("changeStatus")
    @ApiOperation("修改状态接口")
    public ResponseData upStat(
            @ApiParam(name = "id", value = "消息id集合", required = true, type = "string")
            @RequestParam String id){
        service.upStat(id);
        return ResponseData.success();
    }

    @PostMapping("getToDo")
    @ApiOperation("获取待办列表")
    public ResponseData<List<DoReminderDTO>> selectToDo(Integer page, Integer limit,Integer adminId){
        Page<DoReminder> toDoList = service.getToDoList(page,limit,adminId);
        return ResponseData.success(DoReminderDTO.convertList(toDoList.getRecords()), toDoList.getTotal());
    }

    @PostMapping("getMessage")
    @ApiOperation("获取消息列表")
    public ResponseData<List<DoReminderDTO>> selectMessage(Integer page, Integer limit,Integer adminId){
        Page<DoReminder> messageList = service.getMessageList(page,limit,adminId);
        return ResponseData.success(DoReminderDTO.convertList(messageList.getRecords()), messageList.getTotal());
    }

}
